<?php

/**
 * @application Automatical Judging System
 * @author deltamaster
 * @copyright Softrank Research Center
 * @version 2.0.0.0
 */

require_once "./include/common.inc.php";

if (!$uid) showmessage($lang['invalid_operation']);

if (submitcheck('changepassword'))
{
	$originpassword = md5($originpassword);
	
	$query = $db->query("select * from `{$tablepre}user` where `id`='{$uid}' and `password`='{$originpassword}'");
	if ($db->num_rows($query))
	{
		if (VerifyPassword($newpassword))
		{
			$newpassword = md5($newpassword);
			$db->query("update `{$tablepre}user` set `password`='{$newpassword}' where `id`='{$uid}'");
			showmessage($lang['change_password_success'], 'index.php');
		}
		else
		{
			showmessage($lang['password_request'], 'usercp.php');
		}
	}
	else
	{
		showmessage($lang['password_incorrect'], 'usercp.php');
	}
}

if (submitcheck('sendclarification'))
{
	$clarification = sjaddslashes($clarification);
	$db->query("insert into `{$tablepre}record` (`uid`, `pid`, `type`, `event`) values ('{$uid}', '0', 'clarify', '{$clarification}')");
	showmessage($lang['clarify_success'], 'index.php');
}

include template('usercp');

?>